<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
// To verify "mac" behavior other than macOS, please add following lines:
//   internals.settings.setEditingBehavior('mac');
//   internals.settings.setSelectTrailingWhitespaceEnabled(false);
const isMac = navigator.platform.indexOf('Mac') === 0;

selection_test(
  '<div contenteditable dir="rtl">|abc ghi<div><img src=../../resources/abe.png></div><div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">|abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq rst</div>',
  '9-0 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">a|bc ghi<div><img src=../../resources/abe.png></div><div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">|abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq rst</div>',
  '9-1 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">ab|c ghi<div><img src=../../resources/abe.png></div><div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">|abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq rst</div>',
  '9-2 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc| ghi<div><img src=../../resources/abe.png></div><div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">|abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq rst</div>',
  '9-3 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc |ghi<div><img src=../../resources/abe.png></div><div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">|abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq rst</div>',
  '9-4 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc g|hi<div><img src=../../resources/abe.png></div><div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc |ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq rst</div>',
  '9-5 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc gh|i<div><img src=../../resources/abe.png></div><div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc |ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq rst</div>',
  '9-6 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi|<div><img src=../../resources/abe.png></div><div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc |ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq rst</div>',
  '9-7 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div>|<img src=../../resources/abe.png></div><div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi|<div><img src="../../resources/abe.png"></div><div></div><div></div>opq rst</div>',
  '9-8 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png>|</div><div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div>|<img src="../../resources/abe.png"></div><div></div><div></div>opq rst</div>',
  '9-9 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div>|<div></div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png">|</div><div></div><div></div>opq rst</div>',
  '9-10 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div>|</div><div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png">|</div><div></div><div></div>opq rst</div>',
  '9-11 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div></div>|<div></div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png">|</div><div></div><div></div>opq rst</div>',
  '9-12 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div></div><div>|</div>opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png">|</div><div></div><div></div>opq rst</div>',
  '9-13 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div></div><div></div>|opq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png">|</div><div></div><div></div>opq rst</div>',
  '9-14 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div></div><div></div>o|pq rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>|opq rst</div>',
  '9-15 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div></div><div></div>op|q rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>|opq rst</div>',
  '9-16 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div></div><div></div>opq| rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>|opq rst</div>',
  '9-17 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div></div><div></div>opq |rst</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>|opq rst</div>',
  '9-18 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div></div><div></div>opq r|st</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq |rst</div>',
  '9-19 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div></div><div></div>opq rs|t</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq |rst</div>',
  '9-20 rtl right word');

selection_test(
  '<div contenteditable dir="rtl">abc ghi<div><img src=../../resources/abe.png></div><div></div><div></div>opq rst|</div>',
  selection => selection.modify('move', 'right', 'word'),
  '<div contenteditable dir="rtl">abc ghi<div><img src="../../resources/abe.png"></div><div></div><div></div>opq |rst</div>',
  '9-21 rtl right word');
</script>
